<?php

/**
 * Ce fichier contient la classe Form_Diplome
 *
 * @copyright  2012 UVT Oussama Limam
 * @license    "New" GPL3
*/

/**
 *  une entrée Inscription.
 *
 * @copyright  2012 UVT Oussama Limam
 * @license    "New" GPL3
 */
class Application_Form_Inscription  extends Twitter_Bootstrap_Form_Horizontal
{
         
	
	
    public function init()
    {
    	$this->setMethod("post");

    	$decorator=array(
    			array('ViewHelper', array('tag'   => 'div', "class"=>"controls")),
    			array('Label' , array(  "class"=>"control-label")),
    			'Errors',
    			new Zend_Form_Decorator_HtmlTag(array(
    					'tag'   => 'div', "class"=>"control-group"
    			))
    	);
    	
    	$translate = Zend_Registry::get('Zend_Translate');
    	$translate->setLocale('fr');
    	 
    	$cin= new Zend_Form_Element_Text('cin');
    	$cin->setLabel('CIN: ')
    	->setRequired(true);
    	$cin->addValidator('NotEmpty', false, array('messages'=>'Cannot be empty'));
    	
    	$nom= new Zend_Form_Element_Text('nom');
    	$nom->setLabel('Nom: ')
    	->setRequired(true); 
    	$nom->addValidator('NotEmpty', false, array('messages'=>'Cannot be empty'));
    	 
    	$prenom= new Zend_Form_Element_Text('prenom');
    	$prenom->setLabel('Prenom: ')
    	->setRequired(true);
    	$prenom->addValidator('NotEmpty', false, array('messages'=>'Cannot be empty'));
    	 
    	
    	$dn= new Zend_Form_Element_Text('dn');
    	$dn->setLabel('Date de naissance: ')
    	->setRequired(true);
    	$urlhelper=Zend_Controller_Front::getInstance()->getBaseUrl();
    	
    	$adresse= new Zend_Form_Element_Text('adresse');
    	$adresse->setLabel('Adresse: ')
    	->setRequired(true);
    	
    	
    	
    	$universite= new Zend_Form_Element_select('universite');
    	$universite->addMultiOption( "","");
    	
    	$universite->setLabel("Universite: ")
    	->setRequired(true);
    	$univ_model=new Application_Model_DbTable_Universite();
    	$univ_record=$univ_model->fetchAll();
    	$universite->addMultiOption( "","");
    	if($univ_record){
    		$respons=$univ_record->toArray();
    		foreach ($respons as $value){
    			$universite->addMultiOption($value['id_universite'],$value['nom'] );
    		}
    	}
    	//AjaxLoading('$urlhelper/c2i/user/getetab',this.value,'etablissement');
    	$universite->setAttrib("onchange", "AjaxLoading('$urlhelper/c2i/user/getetab',this.value,'etablissement')");
    	
    	$etablissement= new Zend_Form_Element_select('etablissement');
    	$etablissement->addMultiOption( "","");
    	$etablissement->setLabel("Etablissement: ")
    	->setRequired(true);
    	$etab_model=new Application_Model_DbTable_Etablissement();
    	$etab_record=$etab_model->fetchAll();
    	$etablissement->addMultiOption( "","");
    	if($etab_record){
    			$respons=$etab_record->toArray();
    			foreach ($respons as $value){
    		 		$etablissement->addMultiOption($value['id_etablissement'],$value['nom'] );
    			}
    	}
    	
    	
    	
    	 //$etablissement= new Zend_Form_Element_select('etablissement');
    	
    	 //$etablissement->setLabel("Etablissemt: ")
    	 //->setRequired(true);
    	 //$etab_model=new Application_Model_DbTable_Etablissement();
    	// $etab_record=$etab_model->fetchAll();
    	// $etablissement->addMultiOption("","");
    	// if($etab_record){
    	 //	$respons=$etab_record->toArray();
    	 //	foreach ($respons as $value){
    	// 		$etablissement->addMultiOption($value['id_etablissement'],$value['nom'] );
    	 	
    	 
    	$email= new Zend_Form_Element_Text('email');
    	$email->setLabel('Email: ')
    	->setRequired(true);
    	
    	$telephone= new Zend_Form_Element_Text('telephone');
    	$telephone->setLabel('Telephone: ')
    	->setRequired(true);
    	
    	$login= new Zend_Form_Element_Text('login');
    	$login->setLabel("Nom de l'utilisateur: ")
    	->setRequired(true);
    	
    	$password= new Zend_Form_Element_Text('password');
    	$password->setLabel('Mot de passe: ')
    	->setRequired(true);
    	
    	
    	$sendBt = new Zend_Form_Element_Submit('enregistrerdiplome');
    	$sendBt->setLabel('Enregistrer');
    	$sendBt->setAttrib('class', 'btn btn-primary');
    	
    	$annuler = new Zend_Form_Element_Button('Annulerdiplome');
    	$annuler->setLabel('Annuler');
    	$annuler->setAttrib('class', 'btn');
    	
    	
    	$cin->setDecorators($decorator);
    	$nom->setDecorators($decorator);
    	$prenom->setDecorators($decorator);
    	$dn->setDecorators($decorator);
    	$adresse->setDecorators($decorator);
    	$universite->setDecorators($decorator);
    	$etablissement->setDecorators($decorator);
    	$email->setDecorators($decorator);
    	$telephone->setDecorators($decorator);
    	$login->setDecorators($decorator);
    	$password->setDecorators($decorator);
    	
    	
    	$sendBt->setDecorators(array('ViewHelper'));
    	$annuler->setDecorators(array('ViewHelper'));
    	
    	
    	$this->addElements(array($cin,$nom,$prenom,$dn,$adresse,$universite,$etablissement,$email,$telephone,$login,$password,$sendBt,$annuler));
    	
    	 
    	
    }
    
   
    
   
}

